/**
 * @file exec2.c
 * @author liangwenhao (1943080020@qq.com)
 * @brief 
 * @version 0.1
 * @date 2021-07-27
 * 
 * @copyright Copyright (c) 2021
 * 
 * @authorGitee  https://gitee.com/liangwenhao
 * @authorGithub https://github.com/WHaoL
 * @authorBlogs https://blog.csdn.net/liangwenhao1108
 *  
 * @Code Description: P208 测试解释器文件
 *  
 */

#include "apue.h"
#include <sys/wait.h>

int main(void)
{
    pid_t pid;

    if ((pid = fork()) < 0)
    {
        err_sys("fork error");
    }
    else if (pid == 0)
    { /* child */
        if (execl("/home/lwh/ProjsGit/apue/APUE_my/08_Process_Ctl/testinterp",
                  "./testinterp", "myarg1", "MY ARG2", (char *)0) < 0)
            err_sys("execl error");
    }
    if (waitpid(pid, NULL, 0) < 0) /* parent */
        err_sys("waitpid error");
    exit(0);
}

/*
lwh@lwh-HP-Notebook:~/ProjsGit/apue/APUE_my/08_Process_Ctl$ ./exec2
argv[0]: /home/lwh/ProjsGit/apue/APUE_my/07_Process_Env/echoarg
argv[1]: foo
argv[2]: /home/lwh/ProjsGit/apue/APUE_my/08_Process_Ctl/testinterp
argv[3]: myarg1
argv[4]: MY ARG2
*/